
{include file="public/meta" /}
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <!--form元素开始-->
                    <div class="m-t ibox-content layui-form">
                        <input type="hidden" name="id" value="{$this_data.id}"/>
                        <div class="layui-form-item">
                            <label class="layui-form-label">菜单</label>
                            <div class="layui-input-block">
                                <select name="pid" lay-verify="required">
                                    {equal name="this_data.pid" value="0"}
                                        <option value="0">顶级菜单</option>
                                        {volist name="index_menu" id="vo"}
                                            <option value="{$vo.id}">{$vo.title}</option>
                                        {/volist}
                                    {else /}
                                        <option value="0">顶级菜单</option>
                                        {volist name="index_menu" id="vo"}
                                            <option value="{$vo.id}" {equal name="this_data.pid" value="$vo.id"} selected {/equal}>{$vo.title}</option>
                                        {/volist}
                                    {/equal}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">二级栏</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required">
                                    <option value="1" {equal name="this_data.type" value="1"} selected {/equal}>不存在</option>
                                    <option value="2" {equal name="this_data.type" value="2"} selected {/equal}>存在</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">菜单名</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" required  lay-verify="required" placeholder="菜单名" autocomplete="off" class="layui-input" value="{$this_data.title}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">路由</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" required  lay-verify="required" placeholder="顶级菜单输入#（请配置路由）" autocomplete="off" class="layui-input" value="{$this_data.name}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-block">
                                <select name="status" lay-verify="required">
                                    <option value="0">隐藏</option>
                                    <option value="1" {equal name="1" value="$this_data.status"} selected {/equal}>显示</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                                <textarea name="tip" placeholder="备注" class="layui-textarea">{$this_data.tip}</textarea>
                            </div>
                        </div>
                        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element">修改</button>
                        <button type="reset" class="layui-btn layui-btn-warm">重置</button>
                    </div>
                    <!--form元素结束-->
                </div>
            </div>
        </div>
    </div>
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;
            //监听提交
            form.on('submit(component-form-element)', function (data) {
                //$('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
                var index = layer.load();
                $.ajax({
                    url:"{:url('admin/top/top_menu_edit')}",
                    type:'post',
                    dataType:'json',
                    data:data.field,
                    success:function(res){
                        if (res.data == 1) {
                            layer.close(index);
                            layer.msg(res.message);
                        } else if (res.data == 0) {
                            layer.close(index);
                            layer.msg(res.message);
                        } else {
                            layer.close(index);
                            layer.msg('出现未知错误，如果问题一直出现，您可以联系管理员');
                        }
                    },error:function () {
                        layer.close(index);
                        layer.msg('当前网络环境不安全，拒绝登录，请调整网络环境');
                    }
                })
            });
        });
    </script>
    <!-- 全局js -->
    {include file="public/footer" /}
</body>
</html>
